#include<stdio.h>
long long gcd(long long t1, long long t2) {
    return t2 == 0 ? t1 : gcd(t2, t1 % t2);
}

int main()
{
    int m,n;
    scanf("%d%d",&m,&n);
    printf("%d",gcd(m,n));
    return 0;
}